﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class InsXiaoqiu : MonoBehaviour
{
    public GameObject obj;
    public float insInternal;
    public ObjArgs[] mObjArgs;
    float timeNow;
    // Use this for initialization
    void Start()
    {

    }

    // Update is called once per frame
    void Update()
    {
        if(Time.time> timeNow)
        {
            int intId = Random.Range(0, mObjArgs.Length);
            timeNow = Time.time+ insInternal;
           GameObject tempObj=  Instantiate(obj, mObjArgs[intId].pos.position, Quaternion.identity) as GameObject;
            tempObj.transform.GetChild(0).GetComponent<Renderer>().material.color = mObjArgs[intId].colorTemp;
            tempObj.GetComponent<DesIt>().SetLiveTime(mObjArgs[intId].percent);
        }
    }
}

[System.Serializable]
public class ObjArgs
{
    public float percent;
    public Color colorTemp;
    public Transform pos;


}
